﻿using System;
using System.Text;

namespace GPS.GPSLanguage
{
    public enum SelectionMode { Automatic, Manual, Unknown };
    class SelectionModeToken
    {
        public static String[] SelectionModeText = { "Automatic", "Manual", "Unknown" };
        internal static void ParseLanguage(GPSData gpsData, System.Collections.Queue q)
        {
            String token = (string)q.Dequeue();

            String threeDFixToken = (string)q.Dequeue();

            int threeDFix = 0;
            try
            {
                if(threeDFixToken.Length>0)
                    threeDFix = int.Parse(threeDFixToken);
            }
            catch { }

            switch (token)
            {
                case "A":
                    gpsData.SetSelectionModeAnd3dFix(SelectionMode.Automatic, threeDFix);
                    break;
                case "M":
                    gpsData.SetSelectionModeAnd3dFix(SelectionMode.Manual, threeDFix);
                    break;
                default:
                    gpsData.SetSelectionModeAnd3dFix(SelectionMode.Unknown, threeDFix);
                    break;
            }



            switch (gpsData.MessageType)
            {
                case MessageType.GPGSA:
                    PRNToken.ParseLanguage(gpsData, q);
                    break;
                default:
                    throw new InvalidLanguageException("How did you get here?");
            }
        }
    }
}
